#ifndef BUILDING_H
#define BUILDING_H

#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include <QPainter>
#include <QBitmap>
#include <QGraphicsSceneHoverEvent>
#include <QList>

#include "gameitems.h"
#include "buildingtooltip.h"
#include "person.h"

class Building : public QObject, public QGraphicsPixmapItem
{
    Q_OBJECT

public:
    Building(QPoint enterence, QPixmap buildingPixmap, QGraphicsScene * scene);

    void addPerson(Person * newPerson);
    void removePerson(Person * oldPerson);
    void advance(int phase);
    QPoint getEnterencePoint();
    //This is very bad practice here. Feel free to fix it for me,
    //but the tool class needs to be able to see the people
    QList<Person*> CurrentPeopleAccessor();

signals:
    void clicked(Building * sender);

private:
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
    void hoverMoveEvent(QGraphicsSceneHoverEvent *event);

private:
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    QPixmap overlayPixmap;

    QList<Person*> currentPeople;
    qreal buildingHealth;
    int infectedPeople;

    BuildingToolTip * toolTip;
    
    QPoint enterencePoint;
};

#endif // BUILDING_H
